package com.example.wb.myfirstandroid;

import android.support.annotation.LayoutRes;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.FrameLayout;

public abstract class BaseActivity extends AppCompatActivity {

    private Button btnBack;
    private FrameLayout flContentView;
    private Button btnLogin;
    protected int layoutId;

    protected abstract int getLayoutId();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        layoutId=getLayoutId();
        setContentView(layoutId);

        btnBack=(Button) findViewById(R.id.btnTitleBack);
        flContentView=(FrameLayout) findViewById(R.id.contentView);
        btnLogin=(Button) findViewById(R.id.btn_login);
        if(btnBack!=null) {
            btnBack.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    finish();
                }
            });
        }
        //addViewToContent(layoutId);
    }


    protected void addViewToContent(@LayoutRes int id)
    {
        flContentView.addView(LayoutInflater.from(this).inflate(id,null));
    }

}
